package com.luo.service.impl;

import com.luo.mapper.UserMapper;
import com.luo.pojo.User;
import com.luo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserServiceImpl implements UserService {
    private UserMapper userMapper;

    @Autowired
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        log.info("deleteByPrimaryKey id: {}", id);
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(User record) {
        log.info("insert record: {}", record);
        return userMapper.insert(record);
    }

    @Override
    public int insertSelective(User record) {
        log.info("insertSelective record: {}", record);
        return userMapper.insertSelective(record);
    }

    @Override
    public User selectByPrimaryKey(Long id) {
        log.info("selectByPrimaryKey id: {}", id);
        User user = userMapper.selectByPrimaryKey(id);
        log.info("selectByPrimaryKey result: {}", user);
        return user;
    }

    @Override
    public int updateByPrimaryKeySelective(User record) {
        log.info("updateByPrimaryKeySelective record: {}", record);
        return userMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(User record) {
        log.info("updateByPrimaryKey record: {}", record);
        return userMapper.updateByPrimaryKey(record);
    }
}
